home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performDuplicateCurve.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  10.6 KB  |  415 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  11 April 1997
  22. //  Author:         ms
  23. //
  24. //  Description:
  25. //        Initialize the option values for duplicate curve menu item.
  26. //
  27. //  Input Arguments:
  28. //      int action
  29. //          0 - just execute the duplicate curve operation
  30. //        1 - show the option box dialog
  31. //          2 - drag to shelf
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36.  
  37. proc setOptionVars(int $forceFactorySettings)
  38. {
  39.     if ($forceFactorySettings || !`optionVar -exists duplicateCurveLocal`) {
  40.         optionVar -intValue duplicateCurveLocal 0;
  41.     }
  42.     if ($forceFactorySettings || !`optionVar -exists duplicateCurveIsoparms`) {
  43.         optionVar -intValue duplicateCurveIsoparms 2;
  44.     }
  45. }
  46.  
  47. //
  48. //  Procedure Name:
  49. //      duplicateCurveSetup
  50. //
  51. //  Description:
  52. //        Update the state of the option box UI to reflect the duplicate curve
  53. //        option values.
  54. //
  55. //  Input Arguments:
  56. //      parent               - Top level parent layout of the option box UI.
  57. //                             Required so that UI object names can be 
  58. //                             successfully resolved.
  59. //
  60. //        forceFactorySettings - Whether the option values should be set to
  61. //                             default values.
  62. //
  63. //  Return Value:
  64. //      None.
  65. //
  66. global proc duplicateCurveSetup( string $parent,
  67.                                  int $forceFactorySettings,
  68.                                  string $goToTool )
  69. {
  70.     //    Retrieve the option settings
  71.     //
  72.     setOptionVars($forceFactorySettings);
  73.     duplicateCurveToolSetup( $forceFactorySettings, $goToTool );
  74.     setParent $parent;
  75.  
  76.     //    Query the optionVar's and set the values into the controls.
  77.  
  78.     int $local = `optionVar -query duplicateCurveLocal`;
  79.     checkBoxGrp -edit -v1 $local localButton;
  80.  
  81.     int $iso = `optionVar -query duplicateCurveIsoparms`;
  82.     radioButtonGrp -edit -select ($iso+1) isoparmsButton;
  83.  
  84.     if( "" != $goToTool ) {
  85.         checkBoxGrp -e -v1 `scriptCtx -q -exitUponCompletion $goToTool`
  86.           scriptToolExtraWidget;
  87.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  88.           scriptToolExtraWidget;
  89.     }
  90. }
  91.  
  92. //
  93. //  Procedure Name:
  94. //      duplicateCurveCallback
  95. //
  96. //  Description:
  97. //        Update the option values with the current state of the option box UI.
  98. //
  99. //  Input Arguments:
  100. //      parent - Top level parent layout of the option box UI.  Required so
  101. //               that UI object names can be successfully resolved.
  102. //
  103. //        doIt   - Whether the command should execute.
  104. //
  105. //  Return Value:
  106. //      None.
  107. //
  108. global proc duplicateCurveCallback( string $parent,
  109.                                     int $doIt,
  110.                                     string $goToTool )
  111. {
  112.     if( "" != $goToTool ) {
  113.         optionVar -iv duplicateCurveEuc `scriptCtx -q -euc $goToTool`;
  114.         optionVar -iv duplicateCurveLac `scriptCtx -q -lac $goToTool`;
  115.     }
  116.     setParent $parent;
  117.  
  118.     //    Set the optionVar's from the control values, and then
  119.     //    perform the command.
  120.  
  121.     int $local = `checkBoxGrp -query -v1 localButton`;
  122.     optionVar -intValue duplicateCurveLocal $local;
  123.  
  124.     int $iso = `radioButtonGrp -query -select isoparmsButton`;
  125.     optionVar -intValue duplicateCurveIsoparms ($iso-1);
  126.  
  127.     if( 1 == $doIt ) {
  128.         performDuplicateCurve( 0, $goToTool ); 
  129.         string $tmpCmd = "performDuplicateCurve( 0, \"" + $goToTool + "\")";
  130.         addToRecentCommandQueue $tmpCmd "Duplicate Surface Curves";
  131.     }
  132.     else if( $doIt ) {
  133.         setToolTo $goToTool;
  134.     }
  135. }
  136.  
  137. //
  138. //  Procedure Name:
  139. //      duplicateCurveUI
  140. //
  141. //  Description:
  142. //        Fill the contents of the option box for duplicate curve command.
  143. //
  144. //  Input Arguments:
  145. //      The name of the parent layout.
  146. //
  147. //  Return Value:
  148. //      None.
  149. //
  150. proc duplicateCurveUI(string $parent, string $goToTool)
  151. {
  152.     setParent $parent;
  153.  
  154.     checkBoxGrp -ncb 1
  155.         -label ""
  156.         -label1 "Group With Original"
  157.         localButton;
  158.  
  159.     radioButtonGrp -nrb 3
  160.         -label "Visible Surface Isoparms"
  161.         -label1 "U"
  162.         -label2 "V"
  163.         -label3 "Both"
  164.         isoparmsButton;
  165.  
  166.     if( "" != $goToTool ) {
  167.         separator;
  168.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  169.           -l1 "Exit on Completion"
  170.           -v1 on
  171.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  172.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  173.  
  174.           -l2 "Auto Completion"
  175.           -v2 on
  176.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  177.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  178.           scriptToolExtraWidget;
  179.  
  180.         radioButtonGrp -e -enable false isoparmsButton;
  181.     }
  182. }
  183.  
  184. //
  185. //  Procedure Name:
  186. //      duplicateCurveOptions
  187. //
  188. //  Description:
  189. //        Construct the option box UI.  Involves accessing the standard option
  190. //        box and customizing the UI accordingly.
  191. //
  192. //  Input Arguments:
  193. //      None.
  194. //
  195. //  Return Value:
  196. //      None.
  197. //
  198. proc duplicateCurveOptions( int $inTheTool, string $goToTool )
  199. {
  200.     //    Name of the command for this option box.
  201.     //
  202.     string $commandName = "duplicateCurve";
  203.  
  204.     //    Build the option box actions.
  205.     //
  206.     string $callback = ($commandName + "Callback");
  207.     string $setup = ($commandName + "Setup");
  208.  
  209.     //  The value returned is the name of the layout to be used as
  210.     //    the parent for the option box UI.
  211.     //
  212.     global string $gOptionBoxActionToolItem;
  213.     $gOptionBoxActionToolItem = "modelWithToolDuplCurve";
  214.     global string $gOptionBoxActionToolItemCB;
  215.     $gOptionBoxActionToolItemCB = "duplicateCurveToolScript 3";
  216.  
  217.     string $layout = getOptionBox();
  218.     setParent $layout;
  219.     
  220.     //    Pass the command name to the option box.
  221.     //
  222.     //    Any default option box behavior based on the command name is set 
  223.     //    up with this call.
  224.     //
  225.     setOptionBoxCommandName($commandName);
  226.  
  227.     //    Activate the default UI template so that the layout of this 
  228.     //    option box is consistent with the layout of the rest of the 
  229.     //    application.
  230.     //
  231.     setUITemplate -pushTemplate DefaultTemplate;
  232.  
  233.     //    Turn on the wait cursor.
  234.     //
  235.     waitCursor -state 1;
  236.  
  237.     //    RECOMMENDATION:  Place the UI in a scroll layout.  If the 
  238.     //    option box window is ever resized such that it's entire 
  239.     //    contents is not visible then the scroll bars provided by the
  240.     //    scroll layout will allow the user to access the hidden UI.
  241.     //
  242.     tabLayout -scr true -tv false;
  243.     
  244.     string $parent = `columnLayout -adjustableColumn 1`;
  245.  
  246.     //    Create the UI for the tab that is initially visible.
  247.     //
  248.     duplicateCurveUI($parent, $goToTool);
  249.  
  250.     //    Turn off the wait cursor.
  251.     //
  252.     waitCursor -state 0;
  253.  
  254.     //    Deactivate the default UI template.
  255.     //
  256.     setUITemplate -popTemplate;
  257.  
  258.     //    'Duplicate' button.
  259.     //
  260.     string $applyBtn = getOptionBoxApplyBtn();
  261.     if( $inTheTool ) {
  262.         button -edit
  263.           -label "Duplicate Tool"
  264.           -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  265.         $applyBtn;
  266.     }
  267.     else {
  268.         button -edit
  269.           -label "Duplicate"
  270.           -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  271.         $applyBtn;
  272.     }
  273.  
  274.     //    'Save' button.
  275.     //
  276.     string $saveBtn = getOptionBoxSaveBtn();
  277.     button -edit 
  278.         -command ($callback + " " + $parent + " 0 \"" +
  279.                   $goToTool + "\"; hideOptionBox")
  280.         $saveBtn;
  281.  
  282.     //    'Reset' button.
  283.     //
  284.     string $resetBtn = getOptionBoxResetBtn();
  285.     button -edit 
  286.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  287.         $resetBtn;
  288.  
  289.     //    Set the option box title.
  290.     //
  291.     if( $inTheTool ) {
  292.         setOptionBoxTitle("Duplicate Surface Curves Tool Options");
  293.     }
  294.     else {
  295.         setOptionBoxTitle("Duplicate Surface Curves Options");
  296.     }
  297.  
  298.     //    Customize the 'Help' menu item text.
  299.     //
  300.     setOptionBoxHelpTag( "DuplicateSurfaceCurves" );
  301.  
  302.     //    Set the current values of the option box.
  303.     //
  304.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  305.     
  306.     //    Show the option box.
  307.     //
  308.     showOptionBox();
  309. }
  310.  
  311. //
  312. //  Procedure Name:
  313. //      duplicateCurveHelp
  314. //
  315. //  Description:
  316. //        Returns a short description about the duplicate curve command.
  317. //
  318. //  Input Arguments:
  319. //      None.
  320. //
  321. //  Return Value:
  322. //      string.
  323. //
  324. proc string attachHelp()
  325. {
  326.     return 
  327.     "  Command: Duplicate Curve - make a 3D curve from a 2D curve.\n" +
  328.     "Selection: curve on surface, surface isoparam, trimmed surface boundary.";    
  329. }
  330.  
  331. //
  332. //  Procedure Name:
  333. //      assembleCmd
  334. //
  335. //  Description:
  336. //        Construct the duplicate curve command that will apply the option
  337. //      box values.
  338. //
  339. //  Input Arguments:
  340. //      None.
  341. //
  342. //  Return Value:
  343. //      The duplicate curve command string.
  344. //
  345. proc string assembleCmd()
  346. {
  347.     setOptionVars(false);
  348.  
  349.     // query the settings for cmd(s).    
  350.     //
  351.     string $version = "\"2\"";
  352.     int $doHistory = `constructionHistory -q -tgl`;
  353.     int $curveRangePartial = `optionVar -q duplicateCurveRangePartial`;
  354.     int $local = `optionVar -q duplicateCurveLocal`;
  355.     int $iso = `optionVar -q duplicateCurveIsoparms`;
  356.  
  357.     $cmd = "duplicateCurvePresetArgList" ;
  358.     $cmd = $cmd + "( ";
  359.     $cmd = $cmd + $version;
  360.     $cmd = $cmd + ", {\"" ;
  361.     $cmd = $cmd + $doHistory ;
  362.     $cmd = $cmd + "\",\"" ;
  363.     $cmd = $cmd + $curveRangePartial ;
  364.     $cmd = $cmd + "\",\"" ;
  365.     $cmd = $cmd + $local ;
  366.     $cmd = $cmd + "\",\"" ;
  367.     $cmd = $cmd + $iso ;
  368.     $cmd = $cmd +  "\"} )" ;
  369.  
  370.     return $cmd ;    
  371. }
  372.  
  373. global proc string performDuplicateCurve(int $action, string $goToTool)
  374. //
  375. //  Description:
  376. //        Perform the duplicate curve command using the appropriate 
  377. //        option values.  This procedure will also show the option box
  378. //        window if necessary as well as construct the command string
  379. //        that will invoke the duplicate curve command with the current
  380. //        option box values.
  381. //
  382. //  Input Arguments:
  383. //        $action = 0 ==>do the command.
  384. //        $action = 1 ==>show option box.
  385. //        $action = 2 ==>drag to shelf.
  386. //        $action = 3 ==>set the button to enter the tool
  387. //
  388. //  Return Value:
  389. //      The duplicate curve command string.
  390. //
  391. {
  392.     int $inTheTool = false;
  393.     if( 3 == $action ) {
  394.         $action = 1;
  395.         $inTheTool = true;
  396.     }
  397.  
  398.     string $cmd = "";
  399.     switch ($action) {
  400.       case 0:
  401.         setOptionVars(false);
  402.         $cmd = `assembleCmd`;
  403.         eval($cmd);
  404.         break;
  405.       case 1:
  406.         duplicateCurveOptions( $inTheTool, $goToTool );
  407.         break;
  408.       case 2:
  409.         setOptionVars(false);
  410.         $cmd = `assembleCmd`;
  411.         break;
  412.     }
  413.     return $cmd;
  414. }
  415.